﻿using HalconDotNet;
using Sunny.UI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ZRFCore.MachineVisionAlgorithm.Controls.ZrfWindowControl.Path;

namespace 喷点胶机
{
    public partial class Page_3_TestWatchForm : UIForm
    {
        public event EventHandler? FormHide;
        public Page_3_TestWatchForm()
        {
            InitializeComponent();
            zrf_hWindow1.EnMenuStrip = false;
            zrf_hWindow1.EnImgMoveZoom = false;
        }

        public void ShowInfo(HImage newImg, List<HXLD[]> allXldPaths)
        {
            zrf_hWindow1.HXLDs.Clear();
            for (int i = 0; i < allXldPaths.Count; i++)
            {
                for (int j = 0; j < allXldPaths[i].Length; j++)
                {
                    zrf_hWindow1.HXLDs.Add(new ZRFCore.MachineVisionAlgorithm.Controls.ZrfWindowControl.Object.HXLDWithColor(allXldPaths[i][j], "yellow"));
                }
            }
            zrf_hWindow1.DispImage(newImg);
        }

        public void ShowInfo(HImage newImg, List<XldPath> allXldPaths)
        {
            //zrf_hWindow1.HXLDs.Clear();
            //for (int i = 0; i < allXldPaths.Count; i++)
            //{
            //    for (int j = 0; j < allXldPaths[i].Length; j++)
            //    {
            //        zrf_hWindow1.HXLDs.Add(new ZRFCore.MachineVisionAlgorithm.Controls.ZrfWindowControl.Object.HXLDWithColor(allXldPaths[i][j], "yellow"));
            //    }
            //}
            zrf_hWindow1.XldPaths = allXldPaths;
            zrf_hWindow1.DispImage(newImg);
        }

        private void Page_3_TestWatchForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            e.Cancel = true;
            
            this.Hide();
            if (FormHide != null)
            {
                FormHide.Invoke(this, new EventArgs());
            }
        }
    }
}
